package com.ashin.service.impl;

import com.ashin.bean.User;
import com.ashin.dao.FilmMapper;
import com.ashin.dao.UserDao;
import com.ashin.service.UserService;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    // 注入dao
    @Autowired
    private UserDao userDao;

    @Autowired
    private FilmMapper filmMapper;


    @Override
    public void addUser(User user) {
        userDao.addUser(user);

        filmMapper.select(SelectDSLCompleter.allRows()).forEach(System.out::println);
        System.out.println("-----------------");
        filmMapper.all().forEach(System.out::println);
    }

    @Override
    public User getUserById(Integer userId) {
        return userDao.queryUser(userId);
    }

    @Override
    public List<User> queryAll() {
        return userDao.queryAll();
    }

}
